<?php
class Ab_ImageGIF extends Ab_Image{
	private $path=null;
	
	function __construct($path){
		parent::__construct($path);
		
		$this->path=$path;
		
		if(!@getimagesize($this->path)){
			throw new Exception('The path '.$this->path.' is not a valid image.');
		}		
	}
	
	public function getType(){
		return 'image_gif';
	}
	
	public function makeThumb($dir_path,$width,$height,$width_orig,$height_orig){
		
		$extension=$this->getExtension();
		$thumb_path=$dir_path.'/'.md5($this->path).$extension;
		
		$image_p = imagecreatetruecolor($width, $height);
		
		$image = imagecreatefromgif($this->path);
		//trim image
		imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
		// save image
		imagegif($image_p, $thumb_path, 100);
		imagedestroy($image);
		
		return $thumb_path;
	}
	
	
}
?>
